package lei;

import java.io.File;
import java.util.Observer;

import controller.delegates.EMediumUIDelegate;
import model.EMedium;
import model.lendables.Lendable;
import model.rentals.BookRental;

/**
 * The e-media viewer ui delegate default implementation
 * 
 * @author fmartins
 *
 */
public class LEIEMediaUIDelegate extends EMediumUIDelegate {
	
	private EMedium eMedia;
	
	private BookRental b;
	
	/**
	 * 
	 */
	public void setEMedia (EMedium eMedia) {
		this.eMedia = eMedia;
		b = new BookRental(new Lendable(eMedia.getType(), eMedia.getEMediumProperties()));
	}
	
	/**
	 * 
	 */
	@Override
	public void setObservers() {
		eMedia.notify();
	}

	/**
	 * 
	 */
	@Override
	public void deleteObservers() {
		eMedia.notify();	
	}

	/**
	 * 
	 */
	@Override
	public void setLastPageVisited(int pageNum) {
		b.setLastPageVisited(pageNum);
	}

	/**
	 * 
	 */
	@Override
	public boolean isBookmarked(int pageNum) {
		return b.isBookmarked(pageNum);
	}

	/**
	 * 
	 */
	@Override
	public int getLastPageVisited() {
		return b.getLastPageVisited();
	}

	/**
	 * 
	 */
	@Override
	public File getEMediaFile() {
		return eMedia.getFile();
	}

	/**
	 * 
	 */
	@Override
	public boolean hasAnnotations(int pageNum) {
		return b.hasAnnotations(pageNum);
	}

	/**
	 * 
	 */
	@Override
	public void toggleBookmark(int pageNum) {
		b.toggleBookmark(pageNum);
	}
	
	/**
	 * 
	 */
	@Override
	public EMedium getEMedia() {
		return eMedia;
	}

}
